package util;

import ratkit.repast.RepastScenarioBuilder;
import repast.simphony.context.space.continuous.ContinuousSpaceFactoryFinder;
import repast.simphony.context.space.grid.GridFactoryFinder;
import repast.simphony.space.continuous.RandomCartesianAdder;
import repast.simphony.space.grid.GridBuilderParameters;
import repast.simphony.space.grid.RandomGridAdder;
import repast.simphony.valueLayer.GridValueLayer;
import PredatorPrey.SimpleAgent;

abstract public class PredatorPreyScenarioBuilder extends RepastScenarioBuilder {

	public PredatorPreyScenarioBuilder() {
		getEnvironment().reset();
	}

	@SuppressWarnings("unchecked")
	@Override
	protected void createGridAndContinuousSpace() {
		// The x dimension of the physical space
		int xdim = 50;
		// The y dimension of the physical space
		int ydim = 50;

		// Create a new 2D grid to model the simulation.
		GridFactoryFinder.createGridFactory(null).createGrid(
				"Simple Grid",
				getContext(),
				new GridBuilderParameters<SimpleAgent>(
						new repast.simphony.space.grid.WrapAroundBorders(),
						new RandomGridAdder<SimpleAgent>(), true, xdim, ydim));

		// Create a new 2D continuous space to model the physical space on which
		// the sheep and wolves will move.
		ContinuousSpaceFactoryFinder
				.createContinuousSpaceFactory(null)
				.createContinuousSpace(
						"Continuous Space",
						getContext(),
						new RandomCartesianAdder<SimpleAgent>(),
						new repast.simphony.space.continuous.WrapAroundBorders(),
						xdim, ydim, 1);
		// Create a new 2D value layer to store the state of the grass grid.
		GridValueLayer vl = new GridValueLayer("Grass Field", true,
				new repast.simphony.space.grid.WrapAroundBorders(), xdim, ydim);
		getContext().addValueLayer(vl);
	}

	protected PredatorPreyEnvironment getEnvironment() {
		return PredatorPreyEnvironment.getInstance();
	}
}
